function partialLeft(f, ...outerArgs) {
  return function (...innerArgs) {
    let args = [...outerArgs, ...innerArgs];
    return f.apply(this, args);
  };
}
function partialRight(f, ...outerArgs) {
  return function (...innerArgs) {
    let args = [...innerArgs, ...outerArgs];
    return f.apply(this, args);
  };
}

const f = function (x, y, z) {
  return x * (y - z);
};
console.log(partialLeft(f, 2)(3, 4)); // -2
console.log(partialRight(f, 2)(3, 4)); // 6
const sum = (v1, v2) => v1 + v2;
const increment = partialLeft(sum, 1);
const cuberoot = partialRight(Math.pow, 1 / 3);
console.log(cuberoot(increment(26))); // 3
